home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE02 / TPACK / TPACK.ZIP / INVOICE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-06-01  |  4.8 KB  |  206 lines

  1. {------------------------------------------------------------------------------}
  2. {UNREGISTERED VERSION (6/1/95) PLEASE REDISTRIBUTE IN tPACK.ZIP!
  3.  This revision does not contain everything, nor are the exciting
  4.  DataSetReporter and ExtendedMenu[Item] components included.
  5.  Use SWREG#5906 to receive these, icons and a help file for $130.
  6.  You must register when using this code in a business application!
  7.  You'll receive a license to use this code in up to 50 copies of
  8.  any app you write. In turn you will get responsive e-mail
  9.  tech support and enhancements till I run out of registrations
  10.  or suggestions. Meanwhile.. enjoy the code. Bye! I'll make more.
  11.  {(C)'1995 Michael/Ax-Systems, 71560,1754@Compuserve.com}
  12. {------------------------------------------------------------------------------}
  13.  
  14. unit Invoice;
  15.  
  16. interface
  17.  
  18. uses
  19.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  20.   Forms, Dialogs, StdCtrls, ExtCtrls, Toolbar, MiscComp
  21. , UserInfo, Menus;
  22.  
  23. type
  24.   TInvoiceForm = class(TDemoForm)
  25.     Memo1: TMemo;
  26.     Memo2: TMemo;
  27.     Memo3: TMemo;
  28.     Label1: TLabel;
  29.     MessagePanel2: TMessagePanel;
  30.     Label2: TLabel;
  31.     Label3: TLabel;
  32.     Memo4: TMemo;
  33.     Image1: TImage;
  34.     Memo5: TMemo;
  35.     Button1: TButton;
  36.     Label4: TLabel;
  37.     EdRight1: TEdRight;
  38.     PopupMenu1: TPopupMenu;
  39.     Print1: TMenuItem;
  40.     Close1: TMenuItem;
  41.     procedure Button1Click(Sender: TObject);
  42.     procedure FormActivate(Sender: TObject);
  43.     procedure FormDeactivate(Sender: TObject);
  44.     procedure Memo2Enter(Sender: TObject);
  45.     procedure Memo2Exit(Sender: TObject);
  46.     procedure EdRight1Enter(Sender: TObject);
  47.     procedure EdRight1Exit(Sender: TObject);
  48.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  49.     procedure Close1Click(Sender: TObject);
  50.     procedure Print1Click(Sender: TObject);
  51.   private
  52.     { Private declarations }
  53.     fOnHint: TNotifyevent;
  54.     procedure OnHint(Sender: TObject);
  55.   public
  56.     { Public declarations }
  57.   end;
  58.  
  59.   TInvoice = class(TDialogShell)
  60.   public
  61.     procedure Execute; Override;
  62.   end;
  63.  
  64. implementation
  65.  
  66. {$R *.DFM}
  67.  
  68. const
  69.   InvoiceForm: TInvoiceForm= nil;
  70.  
  71.  
  72. procedure TInvoiceForm.Close1Click(Sender: TObject);
  73. begin
  74.   close;
  75. end;
  76.  
  77. procedure TInvoiceForm.Print1Click(Sender: TObject);
  78. begin
  79.   Button1.Click;
  80. end;
  81.  
  82. procedure TInvoice.Execute;
  83. begin
  84.   if InvoiceForm=nil then begin
  85.     InvoiceForm:=TInvoiceForm.Create(Application);
  86.     with InvoiceForm do begin
  87.       OnClose:=FormClose;
  88.       Show;
  89.       end
  90.     end
  91.   else
  92.     InvoiceForm.BringToFront;
  93. end;
  94.  
  95.  
  96. procedure TInvoiceForm.FormClose(Sender: TObject;
  97.   var Action: TCloseAction);
  98. begin
  99.   AcTion:=caFree;
  100.   InvoiceForm:=nil;
  101. end;
  102.  
  103.  
  104. procedure TInvoiceForm.Button1Click(Sender: TObject);
  105. var
  106.   i,n,h,w:integer;
  107. begin
  108.   Button1.Visible:=False;
  109.   Caption:='Printing '+Caption;
  110.   Enabled:=False;
  111.   h:=Height;
  112.   w:=width;
  113.   Width:=w+200;
  114.   n:=ControlCount-1;
  115.   for i:=0 to n do
  116.     Controls[i].Left:=Controls[i].Left+100;
  117.   Height:=h+450;
  118.   with TMemo.Create(Self) do begin
  119.     Parent:=Self;
  120.     BorderStyle:=bsNone;
  121.     Height:=350;
  122.     Align:=AlBottom;
  123.     Clear;
  124.     with lines do begin
  125.       Add('');
  126.       Add('');
  127.       Add('');
  128.       Add('RETURN ADDRESS');
  129.       Add('');
  130.       Add(Memo2.Text);
  131.       Add('');
  132.       Add('');
  133.       Add('');
  134.       Add('SEND TO');
  135.       Add('');
  136.       Add(Memo1.Text);
  137.       end;
  138.     Print;
  139.     Free;
  140.     end;
  141.   Height:=h;
  142.   for i:=0 to n do
  143.     Controls[i].Left:=Controls[i].Left-100;
  144.   Width:=w;
  145.   Enabled:=True;
  146.   Caption:=Copy(Caption,10,255);
  147.   Button1.Visible:=True;
  148. end;
  149.  
  150. procedure TInvoiceForm.FormActivate(Sender: TObject);
  151. begin
  152.   fOnHint:=Application.OnHint;
  153.   Application.OnHint:=OnHint;
  154. end;
  155.  
  156. procedure TInvoiceForm.FormDeactivate(Sender: TObject);
  157. begin
  158.   Application.OnHint:=fOnHint;
  159. end;
  160.  
  161. procedure TInvoiceForm.OnHint(Sender: TObject);
  162. begin
  163.   with Button1 do
  164.     if Application.Hint='' then
  165.       Caption:='Click to Print the '+Self.Caption
  166.     else
  167.       Caption:=Application.Hint+';  Click to Print';
  168. end;
  169.  
  170. procedure TInvoiceForm.Memo2Enter(Sender: TObject);
  171. begin
  172.   tMemo(Sender).BorderStyle:=bsSingle;
  173. end;
  174.  
  175. procedure TInvoiceForm.Memo2Exit(Sender: TObject);
  176. begin
  177.   tMemo(Sender).BorderStyle:=bsNone;
  178. end;
  179.  
  180. procedure TInvoiceForm.EdRight1Enter(Sender: TObject);
  181. begin
  182.   EdRight1.Font.Style:= EdRight1.Font.Style-[fsUnderline];
  183. end;
  184.  
  185. procedure TInvoiceForm.EdRight1Exit(Sender: TObject);
  186. begin
  187.   EdRight1.Font.Style:= EdRight1.Font.Style+[fsUnderline]
  188. end;
  189.  
  190.  
  191. {-----------------------------------------------------------------------------------------}
  192.  
  193. {
  194. const
  195.   Initialize: Boolean= True;
  196.  
  197. initialization
  198.   if Initialize then
  199.     with TInvoice.Create(Application) do try
  200.       dec(Initialize);
  201.       Execute;
  202.     finally
  203.       Free;
  204.       end;   {}
  205. end.
  206.